﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x02000011 RID: 17
public class DissapearHandler : MonoBehaviour
{
	// Token: 0x06000047 RID: 71 RVA: 0x00008606 File Offset: 0x00006806
	private void Awake()
	{
		this.wep = base.GetComponent<WeaponScript>();
		this.body = base.GetComponent<BodyScript>();
	}

	// Token: 0x06000048 RID: 72 RVA: 0x00008620 File Offset: 0x00006820
	private void Update()
	{
		if (this.body)
		{
			using (List<Rigidbody2D>.Enumerator enumerator = this.body.limbs.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					Rigidbody2D rigidbody2D = enumerator.Current;
					SpriteRenderer component = rigidbody2D.GetComponent<SpriteRenderer>();
					component.color = new Color(component.color.r, component.color.g, component.color.b, this.time);
				}
				goto IL_F0;
			}
		}
		if (this.wep)
		{
			if (this.wep.held)
			{
				this.wep.GetComponent<SpriteRenderer>().color = Color.white;
				Object.Destroy(this);
			}
			else
			{
				SpriteRenderer component2 = this.wep.GetComponent<SpriteRenderer>();
				component2.color = new Color(component2.color.r, component2.color.g, component2.color.b, this.time);
			}
		}
		IL_F0:
		this.time -= Time.deltaTime * 0.3f;
		if (this.time < 0f)
		{
			if (GameManager.main.playerBody != this.body)
			{
				Object.Destroy(base.gameObject);
				return;
			}
			base.gameObject.SetActive(false);
		}
	}

	// Token: 0x040000D6 RID: 214
	private float time = 1f;

	// Token: 0x040000D7 RID: 215
	private WeaponScript wep;

	// Token: 0x040000D8 RID: 216
	private BodyScript body;
}
